package queries;

import java.sql.SQLException;

import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;

import entitys.Request;
import enums.Result;

public class DeleteProductQuery {
	/**
	 * Execute query
	 * @param r
	 * @param conn
	 * @return
	 */
	public static Result exe(Request r,java.sql.Connection conn) {
		
		
		java.sql.Statement stmt;
		
			
			try {
				stmt = conn.createStatement();
				stmt.executeUpdate("DELETE FROM ccrm.product WHERE id="+Integer.parseInt((String)(r.getEntity()))+";");
				
				stmt = conn.createStatement();
				stmt.executeUpdate("DELETE FROM ccrm.productintype WHERE productID="+Integer.parseInt((String)(r.getEntity()))+";");
				
				return Result.OK;
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();return Result.FAILED;
			}
			
			
				
			
	 
		
		
		
	}
}


